﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Collector.PulseFixture
{
    class PulseParser
    {
        public static string AnalysePulseName(string pulseName)
        {
            string nameInfo = "";
            string[] pulseNameArray = pulseName.Split(' ');

            for (int i = 0; i < pulseNameArray.Length; i++)
            {
                nameInfo += AnalyseNameStr(pulseNameArray[i]);
            }
            return nameInfo;
        }//floating excess slippery frequent pulse
        public static string AnalyseNameStr(string nameStr)
        {
            string pulseNameInfo = "";
            switch (nameStr)
            {
                case "deep":
                    pulseNameInfo += "沉";
                    break;
                case "excess":
                    pulseNameInfo += "实";
                    break;
                case "floating":
                    pulseNameInfo += "浮";
                    break;
                case "feeble":
                    pulseNameInfo += "虚";
                    break;
                case "stringy":
                    pulseNameInfo += "弦";
                    break;
                case "tight":
                    pulseNameInfo += "紧";
                    break;
                case "slippery":
                    pulseNameInfo += "滑";
                    break;
                case "hesitant":
                    pulseNameInfo += "涩";
                    break;
                case "slow":
                    pulseNameInfo += "迟";
                    break;
                case "moderate":
                    pulseNameInfo += "缓";
                    break;
                case "frequent":
                    pulseNameInfo += "数";
                    break;
                case "swift":
                    pulseNameInfo += "疾";
                    break;
                case "normal":
                    pulseNameInfo += "平";
                    break;
                case "irregularly-intermittent":
                    pulseNameInfo += "结";
                    break;
                case "regularly-intermittent":
                    pulseNameInfo += "代";
                    break;
                case "irregularly-rapid":
                    pulseNameInfo += "促";
                    break;
                case "other":
                    pulseNameInfo += "其他";
                    break;
                case "pulse":
                    pulseNameInfo += "脉";
                    break;


                default:
                    break;
            }
            return pulseNameInfo;
        }

        public static string AnalysePulsePosition(string pulsePosition)
        {
            string pulsePositionInfo = "";
            string[] pulsePositionArray = pulsePosition.Split(' ');
            switch (pulsePositionArray[0].Trim())
            {
                case "deep":
                    pulsePositionInfo += "沉";
                    break;
                case "normal":
                    pulsePositionInfo += "中";
                    break;
                case "floating":
                    pulsePositionInfo += "浮";
                    break;
            }

            return pulsePositionInfo + " " + pulsePositionArray[pulsePositionArray.Length - 1].Trim();
        }
        public static string AnalysePulseForce(string pulseForce)
        {
            if (pulseForce.Contains("strong"))
                return "有力";
            if (pulseForce.Contains("normal"))
                return "正常";
            if (pulseForce.Contains("weak"))
                return "无力";

            return pulseForce;
        }
        public static string AnalysePulseRate(string pulseRate)
        {
            string pulseRateInfo = "";
            string[] pulseRateArray = pulseRate.Split(' ');
            switch (pulseRateArray[0])
            {
                case "slow":
                    pulseRateInfo += "迟";
                    break;
                case "moderate":
                    pulseRateInfo += "缓";
                    break;
                case "normal":
                    pulseRateInfo += "中";
                    break;
                case "frequent":
                    pulseRateInfo += "数";
                    break;
                case "swift":
                    pulseRateInfo += "疾";
                    break;
                case "fast-irregularly":
                    pulseRateInfo += "快";
                    break;
                case "slow-irregularly":
                    pulseRateInfo += "慢";
                    break;

                default:
                    break;
            }

            return pulseRateInfo + " " + pulseRateArray[pulseRateArray.Length - 1];
        }
        public static string AnalysePulseRhythm(string pulseRhythm)
        {
            if (pulseRhythm.Contains("regular"))
                return "齐";
            if (pulseRhythm.Contains("irregular"))
                return "不齐";

            return pulseRhythm;
        }
        public static string AnalysePulsePotential(string pulsePotential, bool isNervous)
        {
            string pulsePotentialInfo = "";
            if (isNervous)
            {
                if (pulsePotential.Contains("stringy"))
                {
                    isNervous = true;
                    pulsePotentialInfo += "弦";
                }
                else if (pulsePotential.Contains("tight"))
                {
                    isNervous = true;
                    pulsePotentialInfo += "紧";
                }
                else if (pulsePotential.Contains("normal"))
                {
                    isNervous = true;
                    pulsePotentialInfo += "正常";
                }
                else
                {
                    pulsePotentialInfo += "正常";
                }
            }
            else
            {
                if (pulsePotential.Contains("slippery"))
                {
                    isNervous = true;
                    pulsePotentialInfo += "滑";
                }
                else if (pulsePotential.Contains("hesitant"))
                {
                    isNervous = true;
                    pulsePotentialInfo += "涩";
                }
                else if (pulsePotential.Contains("normal"))
                {
                    isNervous = true;
                    pulsePotentialInfo += "正常";
                }
                else
                {
                    pulsePotentialInfo += "正常";
                }
            }

            return pulsePotentialInfo;
        }
    }
}
